<template>
  <downloadExcel
    :data="jsonData"
    :fields="jsonFields"
    worksheet="sheet"
    :name="fileName"
  >
    <el-button type="primary" size="small" icon="el-icon-download"
      >导出Excel</el-button
    >
  </downloadExcel>
</template>

<script>
import Vue from "vue";
import JsonExcel from "vue-json-excel";
Vue.component("downloadExcel", JsonExcel);
export default {
  props: {
    jsonData: {
      default: () => [],
      type: Array
    },
    jsonFields: {
      default: () => {},
      type: Object
    },
    fileName: {
      //文件名称-带后缀
      default: "列表.xls",
      type: String
    }
  },
  data() {
    return {
      selection: [],
      json_fields: {},
      json_data: []
    };
  },
  computed: {
    columns() {
      return this.listRule.filter(v => v.tableVisible);
    }
  },
  methods: {
    toggleRowSelection(row, checked) {
      return this.$refs.table.toggleRowSelection(row, checked);
    },
    clearSelection() {
      return this.$refs.table.clearSelection();
    },
    getSelection() {
      return this.selection;
    }
  }
};
</script>

<style lang="scss" scoped></style>
